#include <msp430x16x.h>

typedef struct{
  char powerData[12];
  char tempearture[2];
  char time[2];
  char ADCSData[6];
  char payloadData[2];
  char payloadEventID;
}__attribute__ ((packed)) _sd_record;
unsigned int mb(char* a) /* 67 instructions excluding repetition */
{
  unsigned int j,h=0;
  for(j=0;j<25;++j)
    h=((h<<5)+h)^a[j];
  return h;
}
unsigned int sax(char* a)/* 91 instructions excluding repetition */
{
  unsigned int j,h=0;
  for(j=0;j<25;++j)
    h^=(h<<5)+(h>>2)+a[j];
  return h;
}
unsigned long int elf(char* a)/* 183 instructions excluding multiple repetitions */
{
  unsigned int j;
  unsigned long int h=0,g=0;
  for(j=0;j<25;++j)
  {
    h=(h<<4)+a[j];
    g=h&0xf0000000;
    if(g!=0)
      h^=g>>24;
    h&=~g;
  }
  return h;
}

int main()
{
  int i;
  _sd_record r;

  P1DIR=0xff;
  P1OUT=0;

  for(i=0;i<0xff;++i)
    nop();

  P1OUT=0xff;
  mb((char*)&r);
  P1OUT=0;

  for(i=0;i<0xff;++i)
    nop();

  P1OUT=0xff;
  sax((char*)&r);
  P1OUT=0;

  for(i=0;i<0xff;++i)
    nop();

  P1OUT=0xff;
  elf((char*)&r);
  P1OUT=0;

  while(1)
    nop();

  return 0;
}
